import request from '@/config/axios'

/** 商品定价-链接信息 */
export interface PriceLink {
  id: number; // 编号
  linkId?: number; // 链接id
  iId?: string; // 款式编码
  linkName?: string; // 链接名称
  userId?: number; // 用户
  shopId: number; // 店铺
  sales: number; // 销售额
  profit: number; // 利润
  platform: string; // 平台
  fixedValue1: number; // 固定值1
  fixedValue2: number; // 固定值2
  rateValue1: number; // 比例值1
  rateValue2: number; // 比例值2
  discount: number; // 折扣
  remark: string; // 备注
}

// 商品定价-链接 API
export const PriceLinkApi = {
  // 查询商品定价-链接分页
  getPriceLinkPage: async (params: any) => {
    return await request.get({url: `/operation/price-link/page`, params})
  },

  // 查询商品定价-链接详情
  getPriceLink: async (id: number) => {
    return await request.get({url: `/operation/price-link/get?id=` + id})
  },

  // 新增商品定价-链接
  createPriceLink: async (data: PriceLink) => {
    return await request.post({url: `/operation/price-link/create`, data})
  },

  // 修改商品定价-链接
  updatePriceLink: async (data: PriceLink) => {
    return await request.put({url: `/operation/price-link/update`, data})
  },

  // 删除商品定价-链接
  deletePriceLink: async (id: number) => {
    return await request.delete({url: `/operation/price-link/delete?id=` + id})
  },

  /** 批量删除商品定价-链接 */
  deletePriceLinkList: async (ids: number[]) => {
    return await request.delete({url: `/operation/price-link/delete-list?ids=${ids.join(',')}`})
  },

  // 导出商品定价-链接 Excel
  exportPriceLink: async (params) => {
    return await request.download({url: `/operation/price-link/export-excel`, params})
  },
  addSkuByGoodsCode: async (data: any) => {
    return await request.post({url: `/operation/price-link/addSkuByGoodsCode`, data})
  },
  addSkuByCombineCode: async (data: any) => {
    return await request.post({url: `/operation/price-link/addSkuByCombineCode`, data})
  },
  batchAddSkuCode: async (data: any) => {
    return await request.post({url: `/operation/price-link/batchAddSkuCode`, data})
  },
  savePricingInfo: async (data: any) => {
    return await request.post({url: `/operation/price-link/savePricingInfo`, data})
  }

}
